<div class="text-right" style="padding-bottom: 5px;">
    <hr />
    <?php if (in_array('search', $button)) : ?>
        <button id="btnSearch" class="ui-state-default ui-corner-all" type="button" style="padding: 2px; margin-top: 5px"><?php echo $html->image('icon/search.png'); ?> Search</button>&nbsp;
    <?php endif; ?>
    <?php if (in_array('print', $button)) : ?>
            <button id="btnPrint" class="ui-state-default ui-corner-all" type="button" style="padding: 2px; margin-top: 5px"><?php echo $html->image('icon/print.png'); ?> Print</button>
    <?php endif; ?>
    <?php if (in_array('excel', $button)) : ?>
                <button id="btnExcel" class="ui-state-default ui-corner-all" type="button" style="padding: 2px; margin-top: 5px"><?php echo $html->image('icon/excel.png'); ?> Excel</button>
    <?php endif; ?>
    <input type="submit" class="hide" id="submitSearch" />
    <input type="hidden" class="hide" id="mode" name="data[mode]" value="" />
</div>
<script type="text/javascript">

    /**
     *  dummy function for before submit form search
     *  ทั้ง 3 ป่มเลย search, print และ excel
     */
    beforeSearch = function() {
        return true;
    };
    $j(function() {
        var action = $j('#btnSearch').parents('form').attr('action');
        $j("#btnSearch").bind("click", function(event) {
            if (beforeSearch()) {
                $j('#indicator').show();
                $j('#reportContent').load(action + '_query', $j(this).parents('form').serializeArray(), function() {
                    $j('#indicator').hide();
                });
                $j('#reportFieldset').show();
            }
        })

        $j("#btnPrint").bind("click", function(event) {
            if (beforeSearch()) {
                $j('#mode').val('print');

                $j(this).parents('form').attr('action', action + '_print').submit();
            }
        })

        $j("#btnExcel").bind("click", function(event) {
            if (beforeSearch()) {
                $j('#mode').val('excel');
                $j(this).parents('form').attr('action', action + '_excel').submit();
            }
        })
    });
</script>